package com.meeting.controller.customer;

import com.meeting.dto.RoomAvailabilityDTO;
import com.meeting.dto.RoomBookDTO;
import com.meeting.dto.RoomQueryDTO;
import com.meeting.entity.EquipmentType;
import com.meeting.entity.Rooms;
import com.meeting.service.EquipmentTypeService;
import com.meeting.service.OrdersService;
import com.meeting.service.RoomsService;
import com.meeting.vo.PageResult;
import com.meeting.vo.Result;
import com.meeting.vo.RoomsVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/customer/meeting")
@Tag(name = "客户会议室接口")
public class CustomerMeetingController {
    @Autowired
    private RoomsService roomsService;

    @Autowired
    private EquipmentTypeService equipmentTypeService;


    @GetMapping
    @Operation(summary = "搜索会议室")
    public Result listRooms(RoomQueryDTO roomQueryDTO){
        log.info("分页查询，条件搜索会议室信息");
        roomQueryDTO.setStatus(1);
        PageResult<RoomsVO> rooms= roomsService.listRooms(roomQueryDTO);
        return Result.success(rooms);
    }


    // 新增：获取会议室详情
    @GetMapping("/{id}")
    @Operation(summary = "获取会议室详情")
    public Result getRoomDetail(@PathVariable Integer id) {
        log.info("获取会议室详情，ID：{}", id);
        RoomsVO room = roomsService.getRoomDetail(id);
        if (room == null) {
            return Result.error("会议室不存在");
        }
        return Result.success(room);
    }

    // 新增：检查会议室可用性
    @GetMapping("/checkAvailability")
    @Operation(summary = "检查会议室可用性")
    public Result checkRoomAvailability(RoomAvailabilityDTO availabilityDTO) {
        log.info("检查会议室可用性：{}", availabilityDTO);
        boolean isAvailable = roomsService.checkRoomAvailability(availabilityDTO);
        return Result.success(isAvailable);
    }

    //  新增：获取所有设备类型
    @GetMapping("/equipment-types")
    @Operation(summary = "获取所有设备类型")
    public Result getEquipmentTypes() {
        log.info("获取所有设备类型");
        List<EquipmentType> equipmentTypes = equipmentTypeService.getAllEquipmentTypes();
        return Result.success(equipmentTypes);
    }




}
